﻿using System;
using System.ComponentModel;
using System.IO;
using System.Runtime.Serialization;

namespace HalconDotNet
{
	/// <summary>Represents an instance of a XLD distance transformation.</summary>
	// Token: 0x02000074 RID: 116
	[Serializable]
	public class HXLDDistTrans : HHandle, ISerializable, ICloneable
	{
		// Token: 0x06001C70 RID: 7280 RVA: 0x0000883B File Offset: 0x00006A3B
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HXLDDistTrans() : base(HHandleBase.UNDEF)
		{
		}

		// Token: 0x06001C71 RID: 7281 RVA: 0x000B089E File Offset: 0x000AEA9E
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HXLDDistTrans(IntPtr handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x06001C72 RID: 7282 RVA: 0x000B08AD File Offset: 0x000AEAAD
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HXLDDistTrans(HHandle handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x06001C73 RID: 7283 RVA: 0x000B08BC File Offset: 0x000AEABC
		private void AssertSemType()
		{
			base.AssertSemType("xld_dist_trans");
		}

		// Token: 0x06001C74 RID: 7284 RVA: 0x000B08C9 File Offset: 0x000AEAC9
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HXLDDistTrans obj)
		{
			obj = new HXLDDistTrans(HHandleBase.UNDEF);
			return obj.Load(proc, parIndex, err);
		}

		// Token: 0x06001C75 RID: 7285 RVA: 0x000B08E4 File Offset: 0x000AEAE4
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HXLDDistTrans[] obj)
		{
			HTuple htuple;
			err = HTuple.LoadNew(proc, parIndex, err, out htuple);
			obj = new HXLDDistTrans[htuple.Length];
			for (int i = 0; i < htuple.Length; i++)
			{
				obj[i] = new HXLDDistTrans(HalconAPI.IsLegacyHandleMode() ? htuple[i].IP : htuple[i].H);
			}
			htuple.Dispose();
			return err;
		}

		/// <summary>
		///   Read an XLD distance transform from a file.
		///   Modified instance represents: Handle of the XLD distance transform.
		/// </summary>
		/// <param name="fileName">Name of the file.</param>
		// Token: 0x06001C76 RID: 7286 RVA: 0x000B0954 File Offset: 0x000AEB54
		public HXLDDistTrans(string fileName)
		{
			IntPtr proc = HalconAPI.PreCall(1353);
			HalconAPI.StoreS(proc, 0, fileName);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Create the XLD distance transform.
		///   Modified instance represents: Handle of the XLD distance transform.
		/// </summary>
		/// <param name="contour">Reference contour(s).</param>
		/// <param name="mode">Compute the distance to points ('point_to_point') or entire segments ('point_to_segment'). Default: "point_to_point"</param>
		/// <param name="maxDistance">Maximum distance of interest. Default: 20.0</param>
		// Token: 0x06001C77 RID: 7287 RVA: 0x000B09A0 File Offset: 0x000AEBA0
		public HXLDDistTrans(HXLDCont contour, string mode, HTuple maxDistance)
		{
			IntPtr proc = HalconAPI.PreCall(1360);
			HalconAPI.Store(proc, 1, contour);
			HalconAPI.StoreS(proc, 0, mode);
			HalconAPI.Store(proc, 1, maxDistance);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(maxDistance);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(contour);
		}

		/// <summary>
		///   Create the XLD distance transform.
		///   Modified instance represents: Handle of the XLD distance transform.
		/// </summary>
		/// <param name="contour">Reference contour(s).</param>
		/// <param name="mode">Compute the distance to points ('point_to_point') or entire segments ('point_to_segment'). Default: "point_to_point"</param>
		/// <param name="maxDistance">Maximum distance of interest. Default: 20.0</param>
		// Token: 0x06001C78 RID: 7288 RVA: 0x000B0A08 File Offset: 0x000AEC08
		public HXLDDistTrans(HXLDCont contour, string mode, double maxDistance)
		{
			IntPtr proc = HalconAPI.PreCall(1360);
			HalconAPI.Store(proc, 1, contour);
			HalconAPI.StoreS(proc, 0, mode);
			HalconAPI.StoreD(proc, 1, maxDistance);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(contour);
		}

		// Token: 0x06001C79 RID: 7289 RVA: 0x000B0A6C File Offset: 0x000AEC6C
		void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
		{
			HSerializedItem hserializedItem = this.SerializeDistanceTransformXld();
			byte[] value = hserializedItem;
			hserializedItem.Dispose();
			info.AddValue("data", value, typeof(byte[]));
		}

		// Token: 0x06001C7A RID: 7290 RVA: 0x000B0AA4 File Offset: 0x000AECA4
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HXLDDistTrans(SerializationInfo info, StreamingContext context)
		{
			HSerializedItem hserializedItem = new HSerializedItem((byte[])info.GetValue("data", typeof(byte[])));
			this.DeserializeDistanceTransformXld(hserializedItem);
			hserializedItem.Dispose();
		}

		/// <summary>Serialize object to binary stream in HALCON format</summary>
		// Token: 0x06001C7B RID: 7291 RVA: 0x000B0AE4 File Offset: 0x000AECE4
		public new void Serialize(Stream stream)
		{
			HSerializedItem hserializedItem = this.SerializeDistanceTransformXld();
			hserializedItem.Serialize(stream);
			hserializedItem.Dispose();
		}

		/// <summary>Deserialize object from binary stream in HALCON format</summary>
		// Token: 0x06001C7C RID: 7292 RVA: 0x000B0AF8 File Offset: 0x000AECF8
		public new static HXLDDistTrans Deserialize(Stream stream)
		{
			HXLDDistTrans hxlddistTrans = new HXLDDistTrans();
			HSerializedItem hserializedItem = HSerializedItem.Deserialize(stream);
			hxlddistTrans.DeserializeDistanceTransformXld(hserializedItem);
			hserializedItem.Dispose();
			return hxlddistTrans;
		}

		// Token: 0x06001C7D RID: 7293 RVA: 0x000B0B1E File Offset: 0x000AED1E
		object ICloneable.Clone()
		{
			return this.Clone();
		}

		// Token: 0x06001C7E RID: 7294 RVA: 0x000B0B28 File Offset: 0x000AED28
		public new HXLDDistTrans Clone()
		{
			HSerializedItem hserializedItem = this.SerializeDistanceTransformXld();
			HXLDDistTrans hxlddistTrans = new HXLDDistTrans();
			hxlddistTrans.DeserializeDistanceTransformXld(hserializedItem);
			hserializedItem.Dispose();
			return hxlddistTrans;
		}

		/// <summary>
		///   Clear a XLD distance transform.
		///   Instance represents: Handle of the XLD distance transform.
		/// </summary>
		// Token: 0x06001C7F RID: 7295 RVA: 0x000B0B50 File Offset: 0x000AED50
		public void ClearDistanceTransformXld()
		{
			IntPtr proc = HalconAPI.PreCall(1351);
			base.Store(proc, 0);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Determine the pointwise distance of two contours using an XLD distance transform.
		///   Instance represents: Handle of the XLD distance transform of the reference contour.
		/// </summary>
		/// <param name="contour">Contour(s) for whose points the distances are calculated.</param>
		/// <returns>Copy of Contour containing the distances as an attribute.</returns>
		// Token: 0x06001C80 RID: 7296 RVA: 0x000B0B84 File Offset: 0x000AED84
		public HXLDCont ApplyDistanceTransformXld(HXLDCont contour)
		{
			IntPtr proc = HalconAPI.PreCall(1352);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, contour);
			HalconAPI.InitOCT(proc, 1);
			int num = HalconAPI.CallProcedure(proc);
			HXLDCont result;
			num = HXLDCont.LoadNew(proc, 1, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(contour);
			return result;
		}

		/// <summary>
		///   Read an XLD distance transform from a file.
		///   Modified instance represents: Handle of the XLD distance transform.
		/// </summary>
		/// <param name="fileName">Name of the file.</param>
		// Token: 0x06001C81 RID: 7297 RVA: 0x000B0BDC File Offset: 0x000AEDDC
		public void ReadDistanceTransformXld(string fileName)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1353);
			HalconAPI.StoreS(proc, 0, fileName);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Deserialize an XLD distance transform.
		///   Modified instance represents: Handle of the deserialized XLD distance  transform.
		/// </summary>
		/// <param name="serializedItemHandle">Handle of the serialized XLD distance  transform.</param>
		// Token: 0x06001C82 RID: 7298 RVA: 0x000B0C28 File Offset: 0x000AEE28
		public void DeserializeDistanceTransformXld(HSerializedItem serializedItemHandle)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1354);
			HalconAPI.Store(proc, 0, serializedItemHandle);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(serializedItemHandle);
		}

		/// <summary>
		///   Serialize an XLD distance transform.
		///   Instance represents: Handle of the XLD distance transform.
		/// </summary>
		/// <returns>Handle of the serialized XLD distance  transform.</returns>
		// Token: 0x06001C83 RID: 7299 RVA: 0x000B0C7C File Offset: 0x000AEE7C
		public HSerializedItem SerializeDistanceTransformXld()
		{
			IntPtr proc = HalconAPI.PreCall(1355);
			base.Store(proc, 0);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HSerializedItem result;
			num = HSerializedItem.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Write an XLD distance transform into a file.
		///   Instance represents: Handle of the XLD distance transform.
		/// </summary>
		/// <param name="fileName">Name of the file.</param>
		// Token: 0x06001C84 RID: 7300 RVA: 0x000B0CC4 File Offset: 0x000AEEC4
		public void WriteDistanceTransformXld(string fileName)
		{
			IntPtr proc = HalconAPI.PreCall(1356);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, fileName);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Set new parameters for an XLD distance transform.
		///   Instance represents: Handle of the XLD distance transform.
		/// </summary>
		/// <param name="genParamName">Names of the generic parameters. Default: "mode"</param>
		/// <param name="genParamValue">Values of the generic parameters. Default: "point_to_point"</param>
		// Token: 0x06001C85 RID: 7301 RVA: 0x000B0D00 File Offset: 0x000AEF00
		public void SetDistanceTransformXldParam(HTuple genParamName, HTuple genParamValue)
		{
			IntPtr proc = HalconAPI.PreCall(1357);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, genParamName);
			HalconAPI.Store(proc, 2, genParamValue);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(genParamName);
			HalconAPI.UnpinTuple(genParamValue);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Set new parameters for an XLD distance transform.
		///   Instance represents: Handle of the XLD distance transform.
		/// </summary>
		/// <param name="genParamName">Names of the generic parameters. Default: "mode"</param>
		/// <param name="genParamValue">Values of the generic parameters. Default: "point_to_point"</param>
		// Token: 0x06001C86 RID: 7302 RVA: 0x000B0D50 File Offset: 0x000AEF50
		public void SetDistanceTransformXldParam(string genParamName, string genParamValue)
		{
			IntPtr proc = HalconAPI.PreCall(1357);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, genParamName);
			HalconAPI.StoreS(proc, 2, genParamValue);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Get the parameters used to build an XLD distance transform.
		///   Instance represents: Handle of the XLD distance transform.
		/// </summary>
		/// <param name="genParamName">Names of the generic parameters. Default: "mode"</param>
		/// <returns>Values of the generic parameters.</returns>
		// Token: 0x06001C87 RID: 7303 RVA: 0x000B0D94 File Offset: 0x000AEF94
		public HTuple GetDistanceTransformXldParam(HTuple genParamName)
		{
			IntPtr proc = HalconAPI.PreCall(1358);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, genParamName);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(genParamName);
			HTuple result;
			num = HTuple.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Get the parameters used to build an XLD distance transform.
		///   Instance represents: Handle of the XLD distance transform.
		/// </summary>
		/// <param name="genParamName">Names of the generic parameters. Default: "mode"</param>
		/// <returns>Values of the generic parameters.</returns>
		// Token: 0x06001C88 RID: 7304 RVA: 0x000B0DEC File Offset: 0x000AEFEC
		public HTuple GetDistanceTransformXldParam(string genParamName)
		{
			IntPtr proc = HalconAPI.PreCall(1358);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, genParamName);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HTuple result;
			num = HTuple.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Get the reference contour used to build the XLD distance transform.
		///   Instance represents: Handle of the XLD distance transform.
		/// </summary>
		/// <returns>Reference contour.</returns>
		// Token: 0x06001C89 RID: 7305 RVA: 0x000B0E3C File Offset: 0x000AF03C
		public HXLDCont GetDistanceTransformXldContour()
		{
			IntPtr proc = HalconAPI.PreCall(1359);
			base.Store(proc, 0);
			HalconAPI.InitOCT(proc, 1);
			int num = HalconAPI.CallProcedure(proc);
			HXLDCont result;
			num = HXLDCont.LoadNew(proc, 1, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Create the XLD distance transform.
		///   Modified instance represents: Handle of the XLD distance transform.
		/// </summary>
		/// <param name="contour">Reference contour(s).</param>
		/// <param name="mode">Compute the distance to points ('point_to_point') or entire segments ('point_to_segment'). Default: "point_to_point"</param>
		/// <param name="maxDistance">Maximum distance of interest. Default: 20.0</param>
		// Token: 0x06001C8A RID: 7306 RVA: 0x000B0E84 File Offset: 0x000AF084
		public void CreateDistanceTransformXld(HXLDCont contour, string mode, HTuple maxDistance)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1360);
			HalconAPI.Store(proc, 1, contour);
			HalconAPI.StoreS(proc, 0, mode);
			HalconAPI.Store(proc, 1, maxDistance);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(maxDistance);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(contour);
		}

		/// <summary>
		///   Create the XLD distance transform.
		///   Modified instance represents: Handle of the XLD distance transform.
		/// </summary>
		/// <param name="contour">Reference contour(s).</param>
		/// <param name="mode">Compute the distance to points ('point_to_point') or entire segments ('point_to_segment'). Default: "point_to_point"</param>
		/// <param name="maxDistance">Maximum distance of interest. Default: 20.0</param>
		// Token: 0x06001C8B RID: 7307 RVA: 0x000B0EEC File Offset: 0x000AF0EC
		public void CreateDistanceTransformXld(HXLDCont contour, string mode, double maxDistance)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1360);
			HalconAPI.Store(proc, 1, contour);
			HalconAPI.StoreS(proc, 0, mode);
			HalconAPI.StoreD(proc, 1, maxDistance);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(contour);
		}
	}
}
